package solitaire.deck;

import java.util.ArrayList;

public class CardCollection extends ArrayList<Card> {

	public void storeLocation()
	{
		for( Card card : this)
        {
        	card.storeLocation();
        }
	}
	
	public void restoreLocation()
	{
		for( Card card : this)
        {
        	card.restoreLocation();
        }
	}
	
	public void setLocation(int x, int y, int yOffset)
	{
		if(this != null)
        {
        	int i = 0;
        	for(Card card : this)
        	{
        		if( card != null)
        		{
        			i++;
            		card.setLocation( x, y+(i*yOffset) );
        		}
        	}
        }
	}
	
	public Card getFirst()
	{
		Card result = null;
		for( Card card : this)
        {
			if(card != null)
    		{
				return card;
    		}
        }
		return result;
	}
	
	public Card getLast()
	{
		Card result = null;
		for( Card card : this)
        {
			if(card != null)
    		{
				result = card;
    		}
        }
		return result;
	}
}
